﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace LambdaBuliderDemo
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            dataGridView1.DataSource = GenData();
            lambdaBuilder1.Init<User>(dataGridView1);
        } 

        public class User
        {
            public int Id { get; set; }
            public string Number { get; set; }
            public string UserName { get; set; }
        }

        private List<User> GenData()
        {
            List<User> lstUser = new List<User>();
            for (int i =1; i <= 100; i++)
            {
                User u = new User();
                u.Id = i;
                u.UserName = "name" + i;
                u.Number = "number" + i;
                lstUser.Add(u);
            }
            return lstUser;
        
        }

        private void button1_Click(object sender, EventArgs e)
        {
            var lambda = lambdaBuilder1.BuildLambda<User>();
            textBox1.Text = lambda.Body.ToString();
        }

    }
}
